<?php
class crud extends CI_Model {
	var $table;
	function __construct() {
		parent::__construct ();
	
		// $this->load->database();  
	}
	
	function newcrud($table) {
		$this->table = $table;
	}
	
	function create($data) {
		
		$this->db->insert ( $this->table, $data );
	
	}
	
	public function read_all() {
		
		$query = $this->db->get ( $this->table );
		return $query->result ();
	}
	
	public function read_byid($id) {
		
		$query = $this->db->get_where ( $this->table, array ('id' => $id ) );
		return $query->result ();
	}
	
	public function updata_byid($id, $data) {
		$this->db->where ( 'id', $id );
		$this->db->update ( $this->table, $data );
	
	}
	
	public function delete($id) {
		$this->db->where ( 'id', $id );
		$this->db->delete ( $this->table );
	}
}
?>